#include "my_head.h"

bool Register(p_user_node head,int *n)
{
    if(head==NULL)
    {
        printf("error\n");
        return false;
    }
    // if(head->next!=NULL&&(head->next->data.user_account.permission==1||head->next->data.user_account.permission==2))
    // {
    //     printf("已成功注册！\n");
    //     printf("============\n");
    //     return false;
    // }
    if(*n==1)
    {
        printf("已达注册上限！\n");
        printf("============\n");
        return false;
    }
    p_user_node b=calloc (1,sizeof(user_node));
    if(b==NULL)
    {
        printf("error\n");
        return false;
    }
    b->next=head->next;
    head->next=b;
    b->data.user_account.permission=0;
    if(b->data.user_account.permission==0)
    {
        printf("请输入你的账号:");
        scanf("%d",&b->data.user_account.id);
        printf("请输入你的密码:");
        scanf("%s",b->data.user_account.password);
        if(b->data.user_account.id==123&&strcmp(b->data.user_account.password,"123")==0)
        {
            printf("该账号已存在！\n");
            printf("===============");
            return false;
        }
        b->data.user_account.permission=1;
        (*n)++;
        printf("注册成功！\n");
        printf("================\n");
        return true;
    }
}